package Oop04;

class MyValue {
    //    通过对象的的方式来交换两个值
    public int val;
}

public class Test{
   public static void swap(MyValue myvalue1,MyValue myvalue2){
        int temp = myvalue1.val;
        myvalue1.val = myvalue2.val;
       myvalue2.val = temp;
    }

    public static void main(String[] args) {
        MyValue myvalue1 = new MyValue();
        MyValue myvalue2 = new MyValue();
        myvalue1.val = 10;
        myvalue2.val = 20;
        System.out.println("交换前："+myvalue1.val+" "+ myvalue2.val);
        swap(myvalue1,myvalue2);
        System.out.println("交换后："+myvalue1.val+" "+ myvalue2.val);

    }
}